import { createRouter, createWebHashHistory,createWebHistory } from 'vue-router'
import HomeView from '../views/HomeView.vue'

const routes = [
  {
    path: '/',
    name: 'home',
    component: HomeView
  },
  {
    path: '/about',
    name: 'about',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "about" */ '../views/AboutView.vue')
  }
]
// vue3
const router = createRouter({
  history: createWebHistory(), // hash 模式 
  routes
})
// vue2
// const router = createRouter({
//   mode: 'hash'
//   routes
// })

// 在vue3 中 取消 next(可写可不写) 使用 return true 或者不return   return false  不通过
// router.beforeEach((to, from, next) => {
//   console.log('我是全局的路由守卫');
//   // return false
//   return true;
// })
export default router
